namespace UniversalAdminSystem.Domian.UserManagement.ValueObj;

public record UserAccount
{
    public string Value { get; }
    private UserAccount(string value)
    {
        if (string.IsNullOrWhiteSpace(value))
            throw new ArgumentException("账号不能为空");
        if (!System.Text.RegularExpressions.Regex.IsMatch(value, @"^[a-zA-Z0-9_]{6,20}$"))
            throw new ArgumentException("账号格式不正确,账号长度为6-20字符");
        Value = value;
    }
    public static UserAccount Create(string value) => new(value);
    public static implicit operator string(UserAccount account) => account.Value;
} 